<?php
namespace Home\Controller;
use Think\Controller;
// use Admin\Home\Model\Websites;

class IndexController extends Controller {

    public function index(){
        $this->display('index/login');
    }

    /***
	login()登陆函数
    ***/
    public function login(){
    	$content=I('post.');
        $web=D('Websites');
    	if(isset($content['login'])){
            $result=$web->logincheck($content['loginaccount'],$content['password']);
    	}else if(isset($content['submit'])){
            if(!empty($content['loginaccount'])&&!empty($content['password'])){
                $result=$web->accountcheck($content['loginaccount']);
                if($result['success']=='0'){
                    $result=array('success'=>'1','msg'=>'用户名已经存在');
                }else{
                    $result=$web->addUser($content);
                    if(isset($result)){
                        $result=array('success'=>'0','msg'=>'注册成功!');
                    }
                }
                
            }else{
                $result=array('success'=>'1','msg'=>'账户或者密码请填写完整!');
            }
    	}
        $this->assign('result',$result);
        $this->display('index/index');
    }
}